<div class="row controls-row pt-0">
    <div class="col me-auto g-0">
        {{ render_pagination(posts, topic.url) }}
    </div> <!-- end span pagination -->

{% if current_user.is_authenticated %}
    <div class="col-auto g-0">
        {% if current_user|can_moderate(topic.forum) or current_user|delete_topic(topic)%}
        <!-- Moderation buttons -->
        <div class="btn-group">
            <button class="btn btn-outline-dark dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
                <span class="fas fa-bars fa-fw" aria-hidden="true"></span> {% trans %}Moderate{% endtrans %}
            </button>
            <ul class="dropdown-menu">

            {% if current_user|delete_topic(topic) %}
            <li>
                <form class="d-inline" method="post" action="{{ url_for('forum.delete_topic', topic_id=topic.id, slug=topic.slug) }}">
                    <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
                    <button class="btn btn-link far text-red" type="button" data-bs-toggle="modal" data-bs-target="#confirmModal" data-tooltip="tooltip" title="{% trans %}Delete this topic{% endtrans %}">
                    <span class="fas fa-trash fa-fw"></span> {% trans %}Delete Topic{% endtrans %}
                    </button>
                </form>
            </li>
            {% endif %}

            {% if current_user|can_moderate(topic.forum) %}
                {% if not topic.locked %}
                <li>
                    <form class="d-inline" method="post" action="{{ url_for('forum.lock_topic', topic_id=topic.id, slug=topic.slug) }}">
                        <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
                        <button class="btn btn-link">
                            <span class="fas fa-lock fa-fw"></span> {% trans %}Lock Topic{% endtrans %}
                        </button>
                    </form>
                </li>
                {% else %}
                <li>
                    <form class="d-inline" method="post" action="{{ url_for('forum.unlock_topic', topic_id=topic.id, slug=topic.slug) }}">
                        <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
                        <button class="btn btn-link">
                            <span class="fas fa-unlock fa-fw"></span> {% trans %}Unlock Topic{% endtrans %}
                        </button>
                    </form>
                </li>
                {% endif %}

                {% if not topic.important %}
                <li>
                    <form class="d-inline" method="post" action="{{ url_for('forum.highlight_topic', topic_id=topic.id, slug=topic.slug) }}">
                        <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
                        <button class="btn btn-link">
                            <span class="fas fa-star fa-fw"></span> {% trans %}Highlight Topic{% endtrans %}
                        </button>
                    </form>
                </li>
                {% else %}
                <li>
                    <form class="d-inline" method="post" action="{{ url_for('forum.trivialize_topic', topic_id=topic.id, slug=topic.slug) }}">
                        <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
                        <button class="btn btn-link">
                            <span class="far fa-star fa-fw"></span> {% trans %}Trivialize Topic{% endtrans %}
                        </button>
                    </form>
                </li>
                {% endif %}
            {% endif %}
            {% if current_user | can_moderate(topic.forum) and current_user.permissions.get('makehidden', False) %}
            <li>
                {% if topic.hidden %}
                <form class="d-inline" method="post" action="{{ url_for('forum.unhide_topic', topic_id=topic.id, slug=topic.slug) }}">
                    <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
                    <button class="btn btn-link">
                        <span class="fas fa-user fa-fw"></span> {% trans %}Unhide Topic{% endtrans %}
                    </button>
                </form>
                {% else %}
                <form class="d-inline" method="post" action="{{ url_for('forum.hide_topic', topic_id=topic.id, slug=topic.slug) }}">
                    <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
                    <button class="btn btn-link">
                        <span class="fas fa-user-secret fa-fw"></span> {% trans %}Hide Topic{% endtrans %}
                    </button>
                </form>
                {% endif %}
            </li>
            {% endif %}
            </ul>
        </div>
        <!-- end Moderation buttons -->
        {% endif %}

        {% if current_user.is_tracking_topic(topic) %}
        <form class="d-inline" method="post" action="{{ url_for('forum.untrack_topic', topic_id=topic.id, slug=topic.slug) }}">
            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
            <button class="btn btn-outline-dark">
                <span class="fas fa-tag fa-fw" aria-hidden="true"></span> {% trans %}Untrack Topic{% endtrans %}
            </button>
        </form>
        {% else %}
        <form class="d-inline" method="post" action="{{ url_for('forum.track_topic', topic_id=topic.id, slug=topic.slug) }}">
            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
            <button class="btn btn-outline-dark">
                <span class="fas fa-tag fa-fw" aria-hidden="true"></span> {% trans %}Track Topic{% endtrans %}
            </button>
        </form>
        {% endif %}

        {% if current_user|post_reply(topic) %}
        <a href="{{ url_for('forum.new_post', topic_id=topic.id, slug=topic.slug) }}" class="btn btn-primary">
            <span class="fas fa-reply fa-fw"></span> {% trans %}Reply{% endtrans %}
        </a>
        {% else %}
        <div class="btn btn-primary"><span class="fa fa-lock fa-fw"></span> {% trans %}Locked{% endtrans %}</div>
        {% endif %}

        {{ run_hook("xfree_tpl_topic_controls", topic=topic) }}
    </div>
{% endif %} {# end current_user.is_authenticated #}
</div>
